# -*- encoding: utf-8 -*-
import os, sys
import smtplib
from smtplib import SMTP_SSL
from email.header import Header
from email.mime.text import MIMEText

mailInfo = {
    "from": "hezhenke123@163.com",
    "to": "hezhenke123@163.com",
    "hostname": "smtp.163.com",
    "username": "hezhenke123@163.com",
    "password": "hezhenke@163.com",
    "mailencoding": "utf-8"
}

def send_mail(to_list,sub,content):  #to_list：收件人；sub：主题；content：邮件内容
    smtp = SMTP_SSL(mailInfo["hostname"])
    smtp.ehlo(mailInfo["hostname"])
    smtp.login(mailInfo["username"], mailInfo["password"])
    msg = MIMEText(content, "plain", mailInfo["mailencoding"])
    msg["Subject"] = Header(sub, mailInfo["mailencoding"])
    msg["from"] = mailInfo["from"]
    msg["to"] = ";".join(to_list)
    smtp.sendmail(mailInfo["from"], mailInfo["to"], msg.as_string())
    smtp.quit()


if __name__ == '__main__':
    send_mail(['hezhenke123@163.com','690484812@qq.com'],'自动化交易','测试报告')